﻿<%--
 *  File:    VisitPlanTempletDetail.jsp
 *  @Author: tendyhu
 *  Date:    2009-9-28 ??06:15:08

 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
   	String strModuleName = "SFE";
  	String privilegeCode = "H0254";
  	String contextPath = request.getContextPath();
%>

<%
    String displayflag = null;
    if(request.getParameter("displayflag")!=null&&request.getParameter("displayflag").length()!=0)
        displayflag=request.getParameter("displayflag");
    if(pageContext.getAttribute("displayflag")!=null)
        displayflag=(String)pageContext.getAttribute("displayflag");
    if(displayflag==null && session.getAttribute("displayflag")!=null)
        displayflag = (String)session.getAttribute("displayflag");
    boolean isView = "view".equalsIgnoreCase(displayflag);
    boolean isEdit = "edit".equalsIgnoreCase(displayflag);
    
%>

<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title><%=label.getLabelName("L_EditWeekVisitPlan")%></title>


<PageFlow:CheckPageFlow pageName="p_visitplantempletdetail"/>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script>

function refreshWindow()
{
	var strUrl="VisitPlanTempletDetail.jsp?contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		strUrl=strUrl+"&visitplantempletid=<custom:write property="visitplantempletid"/>&<%= OvalTools.randomURL() %>";
		location.href=strUrl;
}
<%if(!isView){%>
function page_save(num)
{
	var myform = eval("document.cform"+num);
	if(Number(myform.numrows.value)<1)
	 return;
	
		myform.actionname.value = "save";
 		myform.target="_self";
 		isRunning = true;
 		myform.submit();
}
function page_add(num)
{
	var myform = eval("document.cform"+num);
		
	var strUrl="VisitPlanSelectCustomer.jsp?contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		strUrl=strUrl+"&datetype="+num+"&visitplantempletid=<custom:write property="visitplantempletid"/>&<%= OvalTools.randomURL() %>";
    	
		 var status="height=500, width=800,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
    if(popwindow!=null)
      popwindow.close();
   popwindow=window.open(strUrl, "addwindow", status);
}
function page_delete(num)
{
	var myform = eval("document.cform"+num);
	var details=eval("document.cform"+num+".detailids");
	
	
	if(isNullChecked(details))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
    return;
  }
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
		myform.actionname.value = "delete";
 		myform.target="_self";
 		isRunning = true;
 		myform.submit();
}
function page_move(num)
{
	var myform = eval("document.cform"+num);
	if(Number(myform.numrows.value)<1)
	 return;
	var details=eval("document.cform"+num+".detailids");
	
	
	if(isNullChecked(details))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_MOVE") %>");
    return;
  } 
  var ids ="";
  
  for (var i=0; i<Number(myform.numrows.value); i++)
	{
	  		var checkboxs = eval("myform.detailids_"+num+"_"+i);
	  		
	  	   if(checkboxs.checked)
	  	   {
	  	   	if(ids=="")
	  	   	{
	  	   	ids=checkboxs.value;
	  	  
	  	   	}else{
	  	   	ids=ids+","+checkboxs.value;
	  	   
	  	   	}
	  	   }
	  	   
	 }
	var strUrl="VisitPlanTempletMoveFrm.jsp?contactid=<custom:write property="contactid"/>&orgid=<custom:write property="orgid"/>";
		strUrl=strUrl+"&sourceids="+ids+"&datetype="+(num-1)+"&visitplantempletid=<custom:write property="visitplantempletid"/>&<%= OvalTools.randomURL() %>";
		 var status="height=500, width=800,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
    if(popwindow!=null)
      popwindow.close();
   popwindow=window.open(strUrl, "movewindow", status);
}
<%}%>
</script>	
</head>

<body>
		
    	
 
  <table width="100%" cellspacing="0" cellpadding="0" border="1">
  	<%
  	String[] weekLabelArrs=new String[]{"L_Sunday","L_Monday","L_Tuesday","L_Wednesday","L_Thursday","L_Friday","L_Saturday"};
		HashMap visitplantempletinfo=(HashMap)pageContext.getAttribute("visitplantempletinfo");
		
		Vector vDetails=(Vector)pageContext.getAttribute("visitplantempletdetails");	
		if(vDetails==null)
			vDetails=new Vector();
		int numCurr=0;
		HashMap oneDetail=null;
		
  	for(int i=1;i<=8;i++){
  	
  	if(i%2==1){
  	%>
	<tr>
		<%}%>
	<td width="50%"><%if(i==8){%>&nbsp;<%}else{%>
		<form name="cform<%=i%>" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_visitplantempletdetail">
    <input type="hidden" name="actionname">
    <custom:hidden property="contactid"/>
    <custom:hidden property="orgid"/>
    <custom:hidden property="visitplantempletid"/>
    		
			<table width="100%" cellspacing="0" cellpadding="0">
				<tr>
					<td>
					<table width="100%" cellspacing="0" cellpadding="0">
						<tr class="deepblue-left">
							<%if(!isView){%>
							<td><%=label.getLabelName(weekLabelArrs[i-1])%></td>
							<td class="td_right">
							 <a onClick="page_add('<%=i%>')"><custom:button type="2" label="L_Add" imgsrc="back.gif" border="0" style="width:60"/></a>
							 <a onClick="page_delete('<%=i%>')"><custom:button type="2" label="L_Delete" imgsrc="back.gif" border="0" style="width:60"/></a>
        			 		 <a onClick="page_save('<%=i%>')"><custom:button type="2" label="L_Save" imgsrc="back.gif" border="0" style="width:60"/></a>
							 <%--a onClick="page_move('<%=i%>')"><custom:button type="2" label="L_Move" imgsrc="back.gif" border="0" style="width:60"/></a--%>
							 <%}%>
   					  </td>
						</tr>
					</table>
					</td>
				</tr>
				<tr>
				<td>
					<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
						<tr class="deepblue-left">
							<td class="title_center" width="22">&nbsp;</td>
							<td class="title_center"  width="50" ><%=label.getLabelName("L_CustomerCode")%></td>
          		<td class="title_center"   ><%=label.getLabelName("L_CustomerName")%></td>
          		<td class="title_center"  width="50" ><%=label.getLabelName("L_OrgPCName")%></td>
          		<td class="title_center"  width="50" ><%=label.getLabelName("L_ProcessName")%></td>
          		
          	</tr>	 
          	<%
          	int seq=0;
          	if(numCurr<vDetails.size())
          	{
	          	if(oneDetail==null)
	          	{
	          		oneDetail=(HashMap)vDetails.get(numCurr);
	          		
	          	}
	          	seq=0;
	          	while(true){
	          	
          		Integer oDateType=(Integer)oneDetail.get("datetype");
          		
          		
          		if(oDateType.intValue()==i)
          		{
          			pageContext.setAttribute("onevisitdetail",oneDetail);
          			
          			String strStyleClass="none";
          			if(seq%2==1)
          				strStyleClass="td-listrom";
          				
          			
          					
          		Integer oSeq=new Integer(seq);			
          	%> 
						<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='none'"  onClick="" class="<%=strStyleClass%>"> 
							<td height="22">
								<input type="checkbox" id="detailids_<%=i%>_<%=seq%>" name="detailids" value="<custom:write name="onevisitdetail" property="visitplantempletdetailid" />" class="normalradio">
								<custom:hidden name="onevisitdetail" property="visitplantempletdetailid" colIndex="<%=oSeq%>" />
								
							</td>
							<td><a onclick=""><custom:write name="onevisitdetail" property="customercode" nbsp="true"/></a></td>
							<td><custom:write name="onevisitdetail" property="customershortname" nbsp="true" /></td>
							<td><custom:write name="onevisitdetail" property="globalpcname" nbsp="true"/></td>
							<td><custom:select name="onevisitdetail" property="processid" optionsName="allprocesses" optionValueKey="visitprocessid" optionInnerTextKey="processname"  colIndex="<%=oSeq%>" disabled="true"/></td>
							
						</tr>
					  
			<%
			seq++;
					numCurr++;
          if(numCurr<vDetails.size())
          {
          	oneDetail=(HashMap)vDetails.get(numCurr);
          }
        else
        	break;
			}
		else{
			break;
			}
			}
			}%>
					</table>
					<input type="hidden" name="numrows" value="<%=seq%>"/>
								
				</td>
				</tr>
			</table>	
			</form>  	
			<%
			
			}%>
		</td>
		<%if(i%2==0){%>
	 </tr>
	 <%}
	 }%>
	</table>	
	<table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
  <tr>
    <td class="td_center">
		<a onclick="parent.location.href='VisitPlanTempetSummary.jsp?contactid=<custom:write property="contactid"/>&orgid=<custom:write  property="orgid"/>&<%= OvalTools.randomURL() %>';">
			<custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/>
		</a>
	</td>
</tr>	
</table>
  
</body>

</html>